package com.zht.config;

import com.zht.filter.MyFilter;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;


@Configuration
public class FilterConfig {
    @Bean
    public FilterRegistrationBean<MyFilter> myFilterFilterRegistrationBean(){
        FilterRegistrationBean<MyFilter> registrationBean = new FilterRegistrationBean<>();
        registrationBean.setFilter(new MyFilter());
        // 设置拦截URL
        registrationBean.addUrlPatterns("/test");
        // 设置过滤器的优先级
        registrationBean.setOrder(1);
        return registrationBean;
    }
}
